﻿using CKS2320.Common.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CKS2320.Controller
{
    public partial class Login : Form
    {
        public UserModel user = new();
        public UserModel ParaJsonLoad()
        {
            string filePath = "User.json";
            string text = File.ReadAllText(filePath);
            return JsonConvert.DeserializeObject<UserModel>(text);
        }
        public Login()
        {
            InitializeComponent();
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            user = ParaJsonLoad();
            if (textBox1.Text == user.name && textBox2.Text == user.passward)
            {
                this.Close();
                MessageBox.Show("登录成功");
               
                Form_Para form2 = new Form_Para();
                form2.ShowDialog();


            }
            else
            {
                MessageBox.Show("密码错误，请重新输入");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
